package com.fzn;

import java.util.HashMap;
import java.util.Map;

/**
 * @author fzn
 *
 * //  BQfEcC6kmF 密码
 * @date 2023-09-02 0:28
 */
public class Test {
    public static void main(String[] args) {
        //  获取信息的方式 http://192.168.1.1:8080/cgi-bin/baseinfoSet.cgi
        Map<String, String> map = new HashMap<>();
        map.put("telecomadmin", "70&85&106&73&103&71&54&111&113&74&");
        map.put("useradmin", "105&105&121&102&100&");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String encryptedPassword = entry.getValue();
            String[] parts = encryptedPassword.split("&");
            StringBuilder decryptedPassword = new StringBuilder();
            for (String part : parts) {
                try {
                    int asciiValue = Integer.parseInt(part);
                    char decryptedChar;
                    if (Character.isLowerCase(asciiValue)) {
                        decryptedChar = (char) ((asciiValue - 4 - 'a' + 26) % 26 + 'a');
                    } else if (Character.isUpperCase(asciiValue)) {
                        decryptedChar = (char) ((asciiValue - 4 - 'A' + 26) % 26 + 'A');
                    } else {
                        decryptedChar = (char) asciiValue;
                    }
                    decryptedPassword.append(decryptedChar);
                } catch (NumberFormatException e) {
                    System.err.println("Invalid integer in the encrypted password: " + part);
                }
            }
            String superAdminPassword = decryptedPassword.toString();
            System.out.println(entry.getKey() + " : " + superAdminPassword);
        }

    }
}
